import { createRouter, createWebHistory } from 'vue-router'
import AccessibleMap from '../views/AccessibleMap.vue'
import AdvancedMapboxVectorTiles from '../views/AdvancedMapboxVectorTiles.vue'

const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/',
      name: '/',
      redirect: (to) => {
        // 方法接收目标路由作为参数
        // return 重定向的字符串路径/路径对象
        return { path: '/AccessibleMap', query: { q: to.params.searchText } }
      }
    },
    {
      path: '/AccessibleMap',
      name: 'AccessibleMap',
      component: AccessibleMap
    },
    {
      path: '/AdvancedMapboxVectorTiles',
      name: 'AdvancedMapboxVectorTiles',
      component: AdvancedMapboxVectorTiles
    }
  ]
})

export default router
